package com.controller.infocenter;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.util.StringFinal;

@Controller
@RequestMapping("/jsp/infocenter")
public class PreviewController {

	@RequestMapping(value="/preview")
	public String view(String infourl,HttpServletRequest request,Model model){
		//String sourcefile = request.getServletContext().getRealPath("/"+infourl);
		String[] fileinfo = infourl.split("/")[1].split("\\.");
		if(!fileinfo[1].equals("pdf")){
			String srcf = StringFinal.viewpath+infourl.split("/")[1].split("\\.")[0]+".pdf";
			/*String destfile = request.getServletContext().getRealPath("/"+srcf);
			int result = Office2PDF.office2PDF(sourcefile, destfile);*/
			 model.addAttribute("src", srcf);
		}
		else{
			model.addAttribute("src", infourl);
		}
		return  "infocenter/preview";
	}
}
